package com.huawei.esdk.tp.domain.model;

import java.util.Date;
import java.util.List;
import java.util.Map;
import com.huawei.esdk.platform.common.SDKErrorCode;
import com.huawei.esdk.platform.common.SDKResult;
import com.huawei.esdk.platform.common.exception.SDKException;
import com.huawei.esdk.tp.common.constants.TPConstant;
import com.huawei.esdk.tp.device.oa.IExchangeCapability;
import com.huawei.esdk.tp.device.smc.IConferenceManagerCapability;
import com.huawei.esdk.tp.device.smc.v100r003c10.SMC20V1R3C10IConferenceManagerCapability;
import com.huawei.esdk.tp.domain.model.bean.SiteMCU;

/**
 * 在SMC上管理的，已预订或用来进行预定的会议
 * 
 * @author j00160659
 */
public class ScheduleConference extends Conference
{
    
    private String password;
    
    //C30新增参数
    private String chairmanPassword;
    
    private Integer mediaEncryptType;
    
    private Integer auxVideoFormat;
    
    private Integer auxVideoProtocol;
    
    private Integer cpResouce;
    
    private Integer isRecording;
    
    private String recorderAddr;
    
    private Integer isLiveBroadcast;
    
    private Integer presentation;
    
    private String billCode;
    
    //C50新增
    //召集会议以及会议变更时需要通知的Email邮箱地址
    private String creatorEmail;
    
    private String emailContent;
    
    private String mainSiteUri;
    
    // end
    
    public String getEmailContent()
    {
        return emailContent;
    }
    
    public void setEmailContent(String emailContent)
    {
        this.emailContent = emailContent;
    }
    
    public String getMainSiteUri()
    {
        return mainSiteUri;
    }
    
    public void setMainSiteUri(String mainSiteUri)
    {
        this.mainSiteUri = mainSiteUri;
    }
    
    public ScheduleConference(String id)
    {
        super(id);
    }
    
    public ScheduleConference()
    {
        super(null);
    }
    
    /**
     * 对会议进行调度，分配资源。 根据是否为周期性会议而实例化为SingleConference或PeriodicalConference
     * 预约会议接口，传入的Conference是scheduleConf
     * @return 调度成功后的会议，增加了会议ID字段，
     * @throws SDKException 
     * @see SMC:ScheduleConf
     */
    public SDKResult<ScheduleConference> schedule(ScheduleConference conference)
        throws SDKException
    {
        IConferenceManagerCapability confMgr =
            getDeviceManager().getDeviceServiceProxy(TPConstant.DEV_ID_SMC, IConferenceManagerCapability.class);
        return confMgr.scheduleConference(conference);
    }
    
    /**
     * 对已预订的会议进行重新调度。 对象：普通会议或周期会议的所有会议
     * 
     * @return　调度成功后的会议
     * @throws SDKException 
     * @see SMC:EditFutureConf
     */
    public SDKResult<ScheduleConference> reschedule(ScheduleConference conference)
        throws SDKException
    {
        IConferenceManagerCapability confMgr =
            getDeviceManager().getDeviceServiceProxy(TPConstant.DEV_ID_SMC, IConferenceManagerCapability.class);
        return confMgr.editScheduleConference(conference);
    }
    
    /**
     * 预约周期会议PeriodicalConference 预约会议接口，传入的Conference是scheduleConf
     * @return 调度成功后的会议，增加了会议ID字段，
     * @throws SDKException 
     * @see SMC:ScheduleConf
     */
    public SDKResult<PeriodicalConference> scheduleRecurrence(PeriodicalConference conference)
        throws SDKException
    {
        IConferenceManagerCapability confMgr =
            getDeviceManager().getDeviceServiceProxy(TPConstant.DEV_ID_SMC, IConferenceManagerCapability.class);
        return confMgr.scheduleRecurrenceConference(conference);
    }
    
    /**
     * 对已预订的会议进行重新调度。 对象：普通会议或周期会议的所有会议
     * 
     * @return　调度成功后的会议
     * @throws SDKException 
     * @see SMC:EditFutureConf
     */
    public SDKResult<PeriodicalConference> rescheduleRecurrence(PeriodicalConference conference)
        throws SDKException
    {
        IConferenceManagerCapability confMgr =
            getDeviceManager().getDeviceServiceProxy(TPConstant.DEV_ID_SMC, IConferenceManagerCapability.class);
        return confMgr.editScheduleRecurrenceConference(conference);
    }
    
    /**
     * 取消已预订的会议。 对象：普通会议或周期会议的所有会议
     * 
     * @return
     * @see SMC:DeleteScheduledConf
     */
    public SDKErrorCode cancel()
    {
        //
        return new SDKErrorCode();
    }
    
    /**
     * 延长会议时间。 对象：普通会议或周期会议的所有会议 领域模型调用产品解耦bean
     * 
     * @param prolongMinutes
     * @return
     * @throws SDKException 
     * @see SMC:ProlongScheduledConf
     */
    public SDKErrorCode prolong(String confId, Date beginDate, Integer prolongMinutes)
        throws SDKException
    {
        SDKErrorCode result = null;
        IConferenceManagerCapability confMgr =
            getDeviceManager().getDeviceServiceProxy(TPConstant.DEV_ID_SMC, IConferenceManagerCapability.class);
        result = confMgr.prolongScheduleConf(confId, beginDate, prolongMinutes);
        
        return result;
    }
    
    /**
     * @param siteUri
     * @return
     * @throws SDKException 
     * @see SMC:AddSiteInScheduledConf
     */
    public SDKResult<ScheduleConference> addSite(Site site, boolean useAnonymousSite)
        throws SDKException
    {
        IConferenceManagerCapability conferenceManager =
            getDeviceManager().getDeviceServiceProxy(TPConstant.DEV_ID_SMC, IConferenceManagerCapability.class);
        return conferenceManager.addSite(this.getId(), site, this.getBeginTime(), useAnonymousSite);
    }
    
    /**
     * 暂时还保留了原来的removeSite(String siteUri)，等Review确认下来是否让领域模型提供的参数最大化
     * @param beginTime 
     * @param site
     * @return
     * @throws SDKException 
     * @see SMC:DelSiteInScheduledConf
     */
    public SDKErrorCode removeSite(SiteInConference site)
        throws SDKException
    {
        IConferenceManagerCapability conferenceManager =
            getDeviceManager().getDeviceServiceProxy(TPConstant.DEV_ID_SMC, IConferenceManagerCapability.class);
        return conferenceManager.removeSite(this.getId(), site);
    }
    
    /**
     * 连接会场 * @param siteUris /** * @return
     * @throws SDKException 
     */
    public SDKErrorCode connectSites(List<String> siteUris)
        throws SDKException
    {
        IConferenceManagerCapability confMgr =
            getDeviceManager().getDeviceServiceProxy(TPConstant.DEV_ID_SMC, IConferenceManagerCapability.class);
        return confMgr.connectSites(this.getId(), siteUris);
    }
    
    /**
     * 断开会场 
     * * @param siteUris /** * @return
     * @throws SDKException 
     */
    public SDKErrorCode disconnectSites(List<String> siteUris)
        throws SDKException
    {
        IConferenceManagerCapability confMgr =
            getDeviceManager().getDeviceServiceProxy(TPConstant.DEV_ID_SMC, IConferenceManagerCapability.class);
        return confMgr.disconnectSites(this.getId(), siteUris);
    }
    
    /**
     * 会场静音 * @param siteUris /** * @param actionCode /** * @return
     * @throws SDKException 
     */
    public SDKErrorCode quietSites(List<String> siteUris, boolean actionCode)
        throws SDKException
    {
        IConferenceManagerCapability confMgr =
            getDeviceManager().getDeviceServiceProxy(TPConstant.DEV_ID_SMC, IConferenceManagerCapability.class);
        return confMgr.quietSites(this.getId(), siteUris, actionCode);
    }
    
    /**
     * 会场闭音 * @param siteUris /** * @param actionCode /** * @return
     * @throws SDKException 
     */
    public SDKErrorCode muteSites(List<String> siteUris, boolean actionCode)
        throws SDKException
    {
        IConferenceManagerCapability confMgr =
            getDeviceManager().getDeviceServiceProxy(TPConstant.DEV_ID_SMC, IConferenceManagerCapability.class);
        return confMgr.muteSites(this.getId(), siteUris, actionCode);
    }
    
    //用于OA插件集成，预约exchange会议
    public SDKResult<String> scheduleExchangeConf(Conference conferenceInfo)
        throws SDKException
    {
        IExchangeCapability exchangeCapability =
            getDeviceManager().getDeviceServiceProxy(TPConstant.DEV_ID_EXCHANGE, IExchangeCapability.class);
        
        return exchangeCapability.scheduleExchangeConf(conferenceInfo);
    }
    
    //用于OA插件集成，删除exchange会议
    public SDKErrorCode cancelExchangeConf(String exchangeConfId)
        throws SDKException
    {
        IExchangeCapability exchangeCapability =
            getDeviceManager().getDeviceServiceProxy(TPConstant.DEV_ID_EXCHANGE, IExchangeCapability.class);
        
        return exchangeCapability.cancelExchangeConf(exchangeConfId);
    }
    
    //用于OA插件集成，修改exchange会议
    public SDKResult<String> editExchangeConf(Conference conf)
        throws SDKException
    {
        IExchangeCapability exchangeCapability =
            getDeviceManager().getDeviceServiceProxy(TPConstant.DEV_ID_EXCHANGE, IExchangeCapability.class);
        
        return exchangeCapability.editExchangeConf(conf);
    }
    
    //用于OA插件集成，查询符合条件的exchange会议
    public SDKResult<Map<String, Conference>> findExchangeConf(Date beginDate, Date endDate, boolean isCreatedByMe)
        throws SDKException
    {
        IExchangeCapability exchangeCapability =
            getDeviceManager().getDeviceServiceProxy(TPConstant.DEV_ID_EXCHANGE, IExchangeCapability.class);
        return exchangeCapability.findExchangeConf(beginDate, endDate, isCreatedByMe);
    }
    
    public String getPassword()
    {
        return password;
    }
    
    public void setPassword(String password)
    {
        this.password = password;
    }
    
    public Integer getMediaEncryptType()
    {
        return mediaEncryptType;
    }
    
    public void setMediaEncryptType(Integer mediaEncryptType)
    {
        this.mediaEncryptType = mediaEncryptType;
    }
    
    public Integer getCpResouce()
    {
        return cpResouce;
    }
    
    public void setCpResouce(Integer cpResouce)
    {
        this.cpResouce = cpResouce;
    }
    
    public Integer getIsRecording()
    {
        return isRecording;
    }
    
    public void setIsRecording(Integer isRecording)
    {
        this.isRecording = isRecording;
    }
    
    public String getRecorderAddr()
    {
        return recorderAddr;
    }
    
    public void setRecorderAddr(String recorderAddr)
    {
        this.recorderAddr = recorderAddr;
    }
    
    public Integer getIsLiveBroadcast()
    {
        return isLiveBroadcast;
    }
    
    public void setIsLiveBroadcast(Integer isLiveBroadcast)
    {
        this.isLiveBroadcast = isLiveBroadcast;
    }
    
    public Integer getPresentation()
    {
        return presentation;
    }
    
    public void setPresentation(Integer presentation)
    {
        this.presentation = presentation;
    }
    
    public String getBillCode()
    {
        return billCode;
    }
    
    public void setBillCode(String billCode)
    {
        this.billCode = billCode;
    }
    
    public Integer getAuxVideoFormat()
    {
        return auxVideoFormat;
    }
    
    public void setAuxVideoFormat(Integer auxVideoFormat)
    {
        this.auxVideoFormat = auxVideoFormat;
    }
    
    public Integer getAuxVideoProtocol()
    {
        return auxVideoProtocol;
    }
    
    public void setAuxVideoProtocol(Integer auxVideoProtocol)
    {
        this.auxVideoProtocol = auxVideoProtocol;
    }
    
    public String getChairmanPassword()
    {
        return chairmanPassword;
    }
    
    public void setChairmanPassword(String chairmanPassword)
    {
        this.chairmanPassword = chairmanPassword;
    }
    
    public String getCreatorEmail()
    {
        return creatorEmail;
    }
    
    public void setCreatorEmail(String creatorEmail)
    {
        this.creatorEmail = creatorEmail;
    }
    
    public SDKResult<List<SiteMCU>> queryConfSiteMCUEx(String confId, List<String> siteUris, Date date)
        throws SDKException
    {
        SMC20V1R3C10IConferenceManagerCapability confMgr =
            getDeviceManager().getDeviceServiceProxy(TPConstant.DEV_ID_SMC,
                SMC20V1R3C10IConferenceManagerCapability.class);
        return confMgr.queryConfSiteMCU(confId, siteUris, date);
    }
}
